[DA] Hash Table
Hash Table: ν€μ κ°μ λ°μ ν€λ₯Ό ν΄μ±νμ¬ λμ¨ indexμ κ°μ μ μ₯νλ μ ν μλ£κ΅¬μ‘°
Hash Func: μ λ ₯λ°μ κ°μ νΉμ λ²μ λ΄ μ«μλ‘ λ³κ²½νλ ν¨μ
Array, Map, Set μΌλ‘ νν κ°λ₯
Code
// Array
const table = [];
table['key'] = 100;
console.log(table['key']);
// Map
const table2 = new Map();
table2.set('key', 100);
console.log(table2['key']); // μλͺ»λ λ°©λ²
console.log(table2.get('key'));
console.log(table2.keys());
console.log(table2.values());
table2.clear();
console.log(table2.keys());
console.log(table2.values());
// Set
const table3 = new Set();
table3.add('key');
console.log(table.has('key'));
Leave a comment